/*
* @Author: taosong
* @Date:   2018-08-24 09:58:33
* @Last Modified by:   taosong
* @Last Modified time: 2018-08-29 20:45:07
*/
import jsonp from 'common/js/jsonp'
import {commonParams, options} from './config'
import axios from 'axios'
//通过jsonp抓取轮播图数据
export function getRecommend() {
  const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'

  const data = Object.assign({}, commonParams, {
    platform: 'h5',
    uin: 0,
    needNewCode: 1
  })

  return jsonp(url, data, options)
}
//抓取歌单数据但这次通过jsonp并不能解决问题要通过对devServer对象的配置进行后端代理的方法进行数据抓取
export function getDiscList() {
  const url = '/api/getDiscList'

  const data = Object.assign({}, commonParams, {
    platform: 'yqq',
    hostUin: 0,
    sin: 0,
    ein: 29,
    sortId: 5,
    needNewCode: 0,
    categoryId: 10000000,
    rnd: Math.random(),
    format: 'json'
  })

  return axios.get(url, {
    params: data
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}